//
//  BQClickFoodView.m
//  BeeQuick
//
//  Created by Vivitickey on 2017/5/4.
//  Copyright © 2017年 test. All rights reserved.
//

#import "BQClickFoodView.h"

@interface BQClickFoodView ()
@property (weak, nonatomic) IBOutlet UILabel *countLabel;

@end

@implementation BQClickFoodView



#pragma mark - 通过类方法, 返回对象 -
+ (instancetype)clickFoodView {
    
    return [[NSBundle mainBundle] loadNibNamed:@"BQClickFoodView" owner:nil options:nil].lastObject;
}


#pragma mark - 点击减少按钮 -
- (IBAction)didClickReduceButton:(id)sender {
    
    // 减少
    self.count--;
    
    _clickDecrement = YES;
    
    [self sendActionsForControlEvents:UIControlEventValueChanged];
    
    
}


#pragma mark - 点击增加按钮 -
- (IBAction)didClickIncreaseButton:(id)sender {
    
    // 增加
    self.count++;
    
    _clickDecrement = NO;
    
    
    [self sendActionsForControlEvents:UIControlEventValueChanged];
    
}



#pragma mark - 重写了cout的set方法 -
- (void)setCount:(NSInteger)count {
    
    _count = count;
    
    _countLabel.text = [NSString stringWithFormat:@"%ld", count];
    
    // 显示/隐藏 countLabel 减少按钮
    _countLabel.hidden = !count;
    
    _reduceButton.hidden = !count;
}

@end
